package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseCategory1;

import com.atguigu.gmall.model.product.BaseCategory2;
import com.atguigu.gmall.model.product.BaseCategory3;
import com.atguigu.gmall.product.dao.BaseCategory3Mapper;
import com.atguigu.gmall.product.service.BaseCategoryService;
import com.baomidou.mybatisplus.extension.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author A
 * @version 1.0
 * @description: CategoryController
 * @date 2024/9/5 7:24
 */
@RestController
@RequestMapping("/admin/product")
public class CategoryController {
    @Autowired
    private BaseCategoryService baseCategoryService;

    @GetMapping("/getCategory1")
    public Result getCategory1(){
        List<BaseCategory1> baseCategory1 = baseCategoryService.getBaseCategory1();

        return Result.ok(baseCategory1);
    }
    //getCategory2/{category1Id}
    @GetMapping("/getCategory2/{category1Id}")
    public Result getCategory2(@PathVariable("category1Id") Long category1Id){
        List<BaseCategory2> baseCategory2 = baseCategoryService.getBaseCategory2(category1Id);
        return Result.ok(baseCategory2);
    }
    @GetMapping("getCategory3/{category2Id}")
    public Result getCategory3(@PathVariable("category2Id") Long category2Id){
        List<BaseCategory3> baseCategory3 = baseCategoryService.getBaseCategory3(category2Id);
        return Result.ok(baseCategory3);
    }

}
